//
//  ResidenceVC.m
//  BasePorject_App
//
//  Created by Yutian Duan on 2019/5/27.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "RewardVC.h"
#import "RewardHeadView.h"
#import "IntegralVC.h"
#import "RewardListVC.h"

@interface RewardVC () <LTSimpleScrollViewDelegate>

@property (nonatomic, assign) NSInteger count;

@property (nonatomic, strong) RewardHeadView *headView;

///! 控制器 和 title
@property (nonatomic, copy) NSArray <BaseViewController *> *viewControllers;
@property (nonatomic, copy) NSArray <NSString *> *titles;

@property (nonatomic, strong) LTLayout *layout;
@property (nonatomic, strong) LTSimpleManager *managerView;

@end

@implementation RewardVC

- (RewardHeadView *)headView {
  if (!_headView) {
    _headView = [[RewardHeadView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth * ITEMPRO)];
  }
  return _headView;
}

- (NSArray <NSString *> *)titles {
  if (!_titles) {
    _titles = @[
                YTLocalizedString(@"积分兑换"),
                [NSString stringWithFormat:@"%@(%zd)",YTLocalizedString(@"我的奖赏"),_count]
                
                ];
  }
  return _titles;
}

- (NSArray <UIViewController *> *)viewControllers {
  if (!_viewControllers) {
    
    IntegralVC *integarlVC = [[IntegralVC alloc] init];
    RewardListVC *rewardListVC = [[RewardListVC alloc] init];
    
    ///! 登录成功
    _viewControllers = @[integarlVC, rewardListVC];
  }
  return _viewControllers;
}

- (LTSimpleManager *)managerView {
  if (!_managerView) {
    
    _layout = [[LTLayout alloc] init];
    _layout.bottomLineHeight = 2.0;
    _layout.bottomLineCornerRadius = 2.0;
    _layout.isAverage = YES;
    _layout.titleColor = DEF_GRAY;
    _layout.titleSelectColor = HEXCOLOR(0x871913);
    //
    _layout.bottomLineColor = HEXCOLOR(0x871913);
    _layout.sliderWidth = ScreenWidth/4;
    _layout.titleViewBgColor = HEXCOLOR(0xf7f8fc);
    _managerView = [[LTSimpleManager alloc] initWithFrame:CGRectMake(0, NavBarHeight, self.view.bounds.size.width, ScreenHeight - NavBarHeight - TabBarHeight) viewControllers:self.viewControllers titles:self.titles currentViewController:self layout:self.layout];
    
    
    /* 设置代理 监听滚动 */
    _managerView.delegate = self;
    /* 设置悬停位置 */
    //        _managerView.hoverY = 64;
    
    
  }
  return _managerView;
}



- (void)viewDidLoad {
  [super viewDidLoad];

}

- (void)createFields {
  [super createFields];
  self.navigationItem.title = YTLocalizedString(@"奖赏");

}

- (void)createViews {
  [super createViews];
  [self.view addSubview:self.managerView];

  
}

- (void)createConfig {
  [super createConfig];
  
  
  __weak typeof(self) weakSelf = self;
  
  //配置headerView
  [self.managerView configHeaderView:^UIView * _Nullable{
    return weakSelf.headView;
  }];
  
  //pageView点击事件
  [self.managerView didSelectIndexHandle:^(NSInteger index) {
    NSLog(@"点击了 -> %ld", index);
    [weakSelf.viewControllers[index] loadData];
  }];
  
  //控制器刷新事件
  [self.managerView refreshTableViewHandle:^(UIScrollView * _Nonnull scrollView, NSInteger index) {
    NSLog(@"刷新");
    
    
    
  }];
  
}



@end
